// 员工页面的api接口

import request from '@/utils/request'

// 获取员工列表
export function sysUser(params) {
  return request({
    url: '/sys/user',
    params
  })
}

// 新增员工
export const sysUserPost = (data) => {
  return request({
    url: '/sys/user',
    method: 'post',
    data
  })
}
// 删除员工
export const sysUserDelete = (id) => {
  return request({
    url: '/sys/user/' + id,
    method: 'delete'
  })
}

// 批量导入员工
export function sysUserBatch(data) {
  return request({
    url: '/sys/user/batch',
    method: 'post',
    data
  })
}

// 保存员工基本信息
export function sysUserPut(data) {
  return request({
    url: '/sys/user/' + data.id,
    method: 'put',
    data
  })
}

// 获取员工个人信息
export function employeesPersonalInfo(id) {
  return request({
    url: `/employees/${id}/personalInfo`
  })
}

// 更新员工个人信息
export function employeesPersonalInfoPut(data) {
  return request({
    url: `/employees/${data.id}/personalInfo`,
    method: 'put',
    data
  })
}

// 获取员工岗位详情
export function employeesJobs(id) {
  return request({
    url: `/employees/${id}/jobs`
  })
}
// 保存员工岗位详情
export function employeesJobsPut(data) {
  return request({
    url: `/employees/${data.id}/jobs`,
    method: 'put',
    data
  })
}

// 给员工分配角色
export function sysUserAssignRoles(id, roleIds) {
  return request({
    url: '/sys/user/assignRoles',
    method: 'put',
    data: {
      id,
      roleIds
    }
  })
}
